package com.tenglong.teacher.ui.dialog;


import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tenglong.teacher.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class PictureDialogFragment extends BaseFromBottomToShowDialogFragment implements View.OnClickListener {

    private View shoot, photoAlbum, cancle;
    private PictureDialogListener listener;

    public PictureDialogFragment() {
    }

    public static PictureDialogFragment getInstance() {
        PictureDialogFragment f = new PictureDialogFragment();
        return f;
    }

    @Override
    protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_picture_dialog, container, false);
    }

    @Override
    protected void viewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        initView(view);
        setListeners();
    }

    private void setListeners() {
        shoot.setOnClickListener(this);
        photoAlbum.setOnClickListener(this);
        cancle.setOnClickListener(this);
    }

    private void initView(View view) {
        shoot = view.findViewById(R.id.shoot);
        photoAlbum = view.findViewById(R.id.photoAlbum);
        cancle = view.findViewById(R.id.cancle);
    }

    @Override
    public void onClick(View v) {
        dismiss();
        switch (v.getId()) {
            case R.id.shoot:
                if (listener != null) {
                    listener.onShoot();
                }
                break;
            case R.id.photoAlbum:
                if (listener != null) {
                    listener.onPhotoAlbum();
                }
                break;
            case R.id.cancle:
                if (listener != null) {
                    listener.onCancle();
                }
                break;
        }
    }

    public PictureDialogFragment setPictureDialogListener(PictureDialogListener listener) {
        this.listener = listener;
        return this;
    }

    public interface PictureDialogListener {
        void onPhotoAlbum();

        void onShoot();

        void onCancle();
    }
}
